package hci.project.general;

import hci.project.model.LAB;
import hci.project.model.LABImageIO;

import java.io.IOException;

import android.app.Activity;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class HciprojectphotoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*
         * read images in assets
         */
        AssetManager am=this.getAssets();
        Bitmap img = null;
        try {
			img=BitmapFactory.decodeStream(am.open("lighthouse.jpg"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
        /*
         * test: convert RGB to LAB
         * output: LAB value of pixel with position (x,y)
         * x: from 0 to width
         * y: from 0 to height
         */////////////////
        LABImageIO io=new LABImageIO();
        
        io.readImage(img);        
        LAB testlab=io.getLAB(0, 0);
        String testtx="L: "+String.valueOf(testlab.getLValue())+
        			  "; A: "+String.valueOf(testlab.getAValue())+
        			  "; B: "+String.valueOf(testlab.getBValue());
        
        ImageView iv=new ImageView(this);
        iv.setImageBitmap(img);

        //TextView tv = new TextView(this);
        //tv.setText(testtx);
        //setContentView(R.layout.main);
        setContentView(iv);
    }
}